/*
 * Copyright (C) 2008 Universidade Federal de Campina Grande
 *  
 * This file is part of OurGrid. 
 *
 * OurGrid is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free 
 * Software Foundation, either version 3 of the License, or (at your option) 
 * any later version. 
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details. 
 * 
 * You should have received a copy of the GNU Lesser General Public License 
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package org.ourgrid.acceptance.worker;

import org.junit.Before;
import org.junit.Test;
import org.ourgrid.acceptance.util.worker.Req_003_Util;
import org.ourgrid.common.interfaces.control.WorkerControl;
import org.ourgrid.reqtrace.ReqTest;
import org.ourgrid.worker.WorkerComponent;
import org.ourgrid.worker.WorkerConstants;

import br.edu.ufcg.lsd.commune.Application;
import static org.junit.Assert.assertTrue;
@ReqTest(reqs="REQ003")
public class Req_003_Test extends WorkerAcceptanceTestCase {
	
	private Req_003_Util req_003_Util = new Req_003_Util(getComponentContext());
	
	@Before
	public void setUp() throws Exception {
		super.setUp();
		workerAcceptanceUtil.simulateAuthentication();
	}
	
	/**
	 * Verifies if the Worker's module was created and if Worker Control was 
	 * bound.
     * 1- Create a Worker.
     * 2- Verify if there are a module named "WORKER".
     * 3- Lookup "WORKER_CONTROL" object and verify if it is a 
     * org.ourgrid.common.interfaces.control.WorkerControl.
	 */
	@ReqTest(test=" AT-003.1", reqs="REQ003")
	@Test public void test_at_003_1_WorkerCreation() throws Exception {
		
		WorkerComponent component = req_003_Util.createWorkerComponent();
		
		assertTrue(isModuleStarted(component, WorkerConstants.MODULE_NAME));
		assertTrue(isBound(component, Application.CONTROL_OBJECT_NAME, WorkerControl.class));
		
	} 

}